package com.zm.demo.controller;

import com.zm.demo.service.DemoService;
import com.zm.demo.dto.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("feign")
public class FeignDemoController {
    @Autowired
    DemoService demoService;

    @GetMapping("add")
    public int add(@RequestParam int p1, @RequestParam int p2) {
        log.info("feign consumer get hello");
        return demoService.add(p1, p2);
    }

    @GetMapping("user")
    public User user() {
        log.info("feign consumer get user");
        return demoService.user();
    }

    @PostMapping("post")
    public String post() {
        log.info("feign consumer post");
        return demoService.post();
    }
    @PostMapping("post/test")
    public String testPost(){
        User user=new User("post",5);
        return  demoService.postAndParam(user);
    }

    @GetMapping("get/test")
    public String testGet(){
        User user=new User("get",6);
        return  demoService.getAndParam(user);
    }
}
